Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ivy): wrap functions from "providers" in parentheses in Closure mode #33609

Conversation

AndrewKushnir
Copy link
Contributor

Due to the fact that Tsickle runs between analyze and transform phases in Angular, Tsickle may transform nodes (add comments with type annotations for Closure) that we captured during the analyze phase. As a result, some patterns where a function is returned from another function may trigger automatic semicolon insertion, which breaks the code (makes functions return undefined instead of a function). In order to avoid the problem, this commit updates the code to wrap all functions in some expression ("privders" and "viewProviders") in parentheses. More info can be found in Tsickle source code here: https://github.com/angular/tsickle/blob/d7974262571c8a17d684e5ba07680e1b1993afdd/src/jsdoc_transformer.ts#L1021

PR Type

What kind of change does this PR introduce?

  • Bugfix

Does this PR introduce a breaking change?

  • Yes
  • No

@AndrewKushnir AndrewKushnir added state: WIP target: patch This PR is targeted for the next patch release comp: ivy labels Nov 6, 2019
@ngbot ngbot bot modified the milestone: needsTriage Nov 6, 2019
@AndrewKushnir AndrewKushnir added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Nov 6, 2019
@AndrewKushnir AndrewKushnir marked this pull request as ready for review November 6, 2019 17:10
@AndrewKushnir AndrewKushnir requested review from a team as code owners November 6, 2019 17:10
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LTGM

  • typo in the commit message: privders => providers
  • a handful of nits - nothing blocking

packages/compiler-cli/test/ngtsc/ngtsc_spec.ts Outdated Show resolved Hide resolved
packages/compiler-cli/test/ngtsc/ngtsc_spec.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/ngtsc/annotations/src/util.ts Outdated Show resolved Hide resolved
}
return visited;
};
return (node: ts.Expression) => ts.visitEachChild(node, visitor, context);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return (node: ts.Expression) => ts.visitEachChild(node, visitor, context);
return node => ts.visitEachChild(node, visitor, context);

@AndrewKushnir
Copy link
Contributor Author

@petebacondarwin @alxhub thanks for the review! I've updated this PR based on the comments:

  • kept more explicit types and parameters as Alex proposed
  • updates description and restructured tests as Pete suggested

Could you please have a quick look again and let me know if you have additional feedback?

Thank you.

@AndrewKushnir AndrewKushnir added the action: presubmit The PR is in need of a google3 presubmit label Nov 14, 2019
Due to the fact that Tsickle runs between analyze and transform phases in Angular, Tsickle may transform nodes (add comments with type annotations for Closure) that we captured during the analyze phase. As a result, some patterns where a function is returned from another function may trigger automatic semicolon insertion, which breaks the code (makes functions return `undefined` instead of a function). In order to avoid the problem, this commit updates the code to wrap all functions in some expression ("privders" and "viewProviders") in parentheses. More info can be found in Tsickle source code here: https://github.com/angular/tsickle/blob/d7974262571c8a17d684e5ba07680e1b1993afdd/src/jsdoc_transformer.ts#L1021
@AndrewKushnir
Copy link
Contributor Author

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 19, 2019
alxhub pushed a commit that referenced this pull request Nov 20, 2019
…ode (#33609)

Due to the fact that Tsickle runs between analyze and transform phases in Angular, Tsickle may transform nodes (add comments with type annotations for Closure) that we captured during the analyze phase. As a result, some patterns where a function is returned from another function may trigger automatic semicolon insertion, which breaks the code (makes functions return `undefined` instead of a function). In order to avoid the problem, this commit updates the code to wrap all functions in some expression ("privders" and "viewProviders") in parentheses. More info can be found in Tsickle source code here: https://github.com/angular/tsickle/blob/d7974262571c8a17d684e5ba07680e1b1993afdd/src/jsdoc_transformer.ts#L1021

PR Close #33609
@alxhub alxhub closed this in fc2f6b8 Nov 20, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants